--
-- Author:      name
-- DateTime:    2018-05-05 15:46:35
-- Description: 炸金花服务
local skynet = require "skynet"
local config = require "configquery"
local queue = require "skynet.queue"

local Objects = require "Objects"
local Message = require "zhajinhua.Message"
local Command = require "zhajinhua.Command"
local Machine = require("zhajinhua.Machine")
local Rule = require("zhajinhua.Rule")

local myqueue = queue()


local param = {...}
local tableid = tonumber(param[1])
local room_type = tonumber(param[2])
local gameName = 'zhajinhua'
g_objects = Objects.new()




---------------------------------------------------------
-- REQUEST
---------------------------------------------------------



---------------------------------------------------------
-- CMD
---------------------------------------------------------


local function init()
	local message = Message.new(gameName)
	g_objects:add(message)

	local rule = Rule.new()
	g_objects:add(rule)

	local machine = Machine.new(tableid)
	g_objects:add(machine)
	machine:start()

	local command = Command.new(message,machine)
	g_objects:add(command)
	g_objects:hotfix(gameName)
		
	local f = message:dispatch()
	function _queue( session, source, cmd, ...)		
		local resut = myqueue(f,session, source, cmd, ...)
		return result
	end	
	skynet.dispatch("lua",_queue)

end

---------------------------------------------------------
-- skynet
---------------------------------------------------------
skynet.start(function()
	init()


end)